﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SMTC.Dao.Line;
using SMTC.Model.Domain;
using System.Data.Common;
using SMTC.Model.Model;
using SMTC.BO.Common;

namespace SMTC.BO.Line
{
    public class LineQueryServices
    {
        private LineQueryDao _dao = new LineQueryDao();
        /// <summary>
        /// 获取一个Line的List
        /// </summary>
        /// <param name="LineName"></param>
        /// <param name="LineTargetTime"></param>
        /// <param name="ModifyPerson"></param>
        /// <param name="LineCapacity"></param>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <returns></returns>
        public List<SMT_LineModel> GetLineList(string LineName, int LineTargetTime, string ModifyPerson, int LineCapacity, DateTime startTime, DateTime endTime)
        {
            LineName = DbValueProccess.StrProccess(LineName);
            ModifyPerson = DbValueProccess.StrProccess(ModifyPerson);
            startTime = DbValueProccess.DateTimeProccess(startTime);
            endTime = DbValueProccess.DateTimeProccess(endTime, false);
            LineTargetTime = DbValueProccess.IntProccess(LineTargetTime);
            LineCapacity = DbValueProccess.IntProccess(LineCapacity);

            return _dao.GetLineList(LineName, LineTargetTime, ModifyPerson, LineCapacity, startTime, endTime);
        }

        /// <summary>
        /// 获取一个Line的List供选择line时使用
        /// </summary>
        /// <param name="LineName"></param>
        /// <param name="LineTargetTime"></param>
        /// <param name="ModifyPerson"></param>
        /// <param name="LineCapacity"></param>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <returns></returns>
        public List<SMT_LineModel> GetLineListForSelect(string LineName, int LineTargetTime, string ModifyPerson, int LineCapacity, DateTime startTime, DateTime endTime)
        {
            LineName = DbValueProccess.StrProccess(LineName);
            ModifyPerson = DbValueProccess.StrProccess(ModifyPerson);
            startTime = DbValueProccess.DateTimeProccess(startTime);
            endTime = DbValueProccess.DateTimeProccess(endTime, false);
            LineTargetTime = DbValueProccess.IntProccess(LineTargetTime);
            LineCapacity = DbValueProccess.IntProccess(LineCapacity);

            return _dao.GetLineListForSelect(LineName, LineTargetTime, ModifyPerson, LineCapacity, startTime, endTime);
        }

        /// <summary>
        /// 获取Line的单个实体
        /// </summary>
        /// <param name="LineID"></param>
        /// <returns></returns>
        public SMT_LineModel GetLineMode(string LineID)
        {
            return _dao.getLineModel(LineID);
        }
        /// <summary>
        /// 获取Line的Domain的list
        /// </summary>
        /// <param name="LineName"></param>
        /// <param name="LineTargetTime"></param>
        /// <param name="ModifyPerson"></param>
        /// <param name="LineCapacity"></param>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <returns></returns>
        public List<LineDomain> GetLineDomainList(string LineName, int LineTargetTime, string ModifyPerson, int LineCapacity, DateTime startTime, DateTime endTime)
        {
            List<LineDomain> domainList = new List<LineDomain>();
            List<SMT_LineModel> modelList = this.GetLineList(LineName, LineTargetTime, ModifyPerson, LineCapacity, startTime, endTime);
            foreach (var item in modelList)
            {
                LineDomain domain = new LineDomain();
                domain.line = item;
                domain.puList = _dao.GetLineProductUnitList(item.LineID);
                domainList.Add(domain);
            }
            return domainList;
        }
        /// <summary>
        /// 获取Line的Domain
        /// </summary>
        /// <param name="LineID"></param>
        /// <returns></returns>
        public LineDomain GetlineDomain(string LineID)
        {
            LineDomain domain = new LineDomain();
            domain.line = this.GetLineMode(LineID);
            domain.puList = _dao.GetLineProductUnitList(LineID);
            return domain;
        }
    }
}
